package cc.comac.mom.datahandlers.entity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cc.comac.mom.dao.entity.CheckSealDao;
import cc.comac.mom.entity.CheckSealEntity;
import cc.comac.mom.util.ResultBean;
import cc.comac.mom.util.user.UserUtil;

@Component
public class CheckSealDataHandler {

	@Autowired
	private UserUtil userUtil;
	@Autowired
	private CheckSealDao checkSealDao;
	
	public ResultBean checkSealInsert(CheckSealEntity checkSealEntity) {
		ResultBean resultBean = new ResultBean(true);
		try {
			updateCheckSealFeild(checkSealEntity);
			checkSealDao.checkSealInsert(checkSealEntity);
		} catch (Exception e) {
			resultBean.setErrorMessge(e.getMessage());
			e.printStackTrace();
		}
		return resultBean;
	}
	public void updateCheckSealFeild(CheckSealEntity checkSealEntity) {
		checkSealEntity.setCheckUser(userUtil.getUserTrueNameInfoByEcode(checkSealEntity.getCheckJobNumber()));
		if (checkSealEntity.getFlag().equals("1")) {
			checkSealEntity.setTableName("quality_qar_check_item");
			checkSealEntity.setIdField("qar_check_item_id");
		}
	}
}
